<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('customer/index')}">客户列表</a></li>
			<li class="active"><a>新增客户</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('customer/add')}">
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>组织</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="form_number">
						<option value="">请选择</option>
						<foreach name="factory_list" item="vo">
							<option value="{$vo.fnumber}">{$vo.fname}</option>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>关键词</label>
				<div class="col-md-6 col-sm-10">
					<input class="form-control" name="key">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>客户</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="customer" id="list">
						<option value="">请选择</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-success select">查询</button>
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
	$('.select').click(function(){
		var forgnumber = $('select[name=form_number]').val();
		var fkey = $('input[name=key]').val();
		if(forgnumber == ''){
			alert('请选择组织！');
			return false;
		}
		if(fkey == ''){
			alert('请输入关键词！');
			return false;
		}
		$.ajax({
			type: 'get',
			url: '{:url("customer/customer")}',
			data: {forgnumber:forgnumber,fkey:fkey},
			success:function(res){
				console.log(res)
				var json = eval(res.data.datas);
				var html = '<option value="">请选择</option>';
				for(var i in json){
					html += '<option value="'+json[i]['fnumber']+'">'+json[i]['fname']+'</option>';
				}
				$('#list').html(html);
			}
		})
	});
	$('select[name=form_number]').change(function(){
		$('#list').html('<option value="">请选择</option>');
	});
	</script>
</body>
</html>